/**
 * Created by admin on 2017/11/9.
 */
function render(data, promotions){
    var html = '';
    for(var i = 0;i<data.length;i++) {
        html += '<div class="row" style="margin-left:0;">' +
            '<select name="type" class="form-control">' +
            '<option value="0"' + (data[i]['type'] == 0 ? 'selected' : '') + '>促销类型</option>' +
            '<option value="1"' + (data[i]['type'] == 1 ? 'selected' : '') + '>限时秒杀</option>' +
            '<option value="2"' + (data[i]['type'] == 2 ? 'selected' : '') + '>限时折扣</option>' +
            '</select>' +
            '<select name="promotion_id" class="form-control">';
        if(typeof(promotions[data[i]['type']]) !=="undefined"){
            for (var j = 0; j < promotions[data[i]['type']].length; j++) {
                html += '<option value="' + promotions[data[i]['type']][j]['id'] + '" ' +
                    (data[i]['promotion_id'] == promotions[data[i]['type']][j]['id'] ? 'selected' : '') +
                    '>' + promotions[data[i]['type']][j]['title'] + '</option>';
            }
        }
        html += '</select>';
        html += '<div class="input-group input-group-sm">';
        html += '<span class="input-group-addon"><strong>促销数量</strong></span>'
        html += '<input style="" type="number" class="form-control input-sm" placeholder="数量" min="0" name="num"' +
            'value="' + data[i]['promotion_num'] + '"/>';
        html += '<span class="input-group-addon"><strong>促销价格</strong></span>';
        html += '<input style="" type="number" class="form-control" placeholder="促销价格" name="price" min="0" value="' +
            data[i]['promotion_price'] + '"/>';
        html += '</div>';
        html += '<button type="button" class="btn btn-xs bg-red del-setting" style="padding:0 6px;"> x </button>';
        html += '</div>';
    }
    return html;
}